<?php

/**
 * Assignment form base class.
 *
 * @method Assignment getObject() Returns the current form's model object
 *
 * @package    ecollegeplus
 * @subpackage form
 * @author     Batanayi Matuku
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseAssignmentForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                    => new sfWidgetFormInputHidden(),
      'title'                 => new sfWidgetFormInputText(),
      'assignment_group_id'   => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('AssignmentGroup'), 'add_empty' => false)),
      'description'           => new sfWidgetFormTextarea(),
      'submission'            => new sfWidgetFormInputText(),
      'due_date'              => new sfWidgetFormDateTime(),
      'points'                => new sfWidgetFormInputText(),
      'weight'                => new sfWidgetFormInputText(),
      'lock_until'            => new sfWidgetFormDateTime(),
      'lock_after'            => new sfWidgetFormDateTime(),
      'notify_users'          => new sfWidgetFormInputCheckbox(),
      'is_graded'             => new sfWidgetFormInputCheckbox(),
      'allow_late_submission' => new sfWidgetFormInputCheckbox(),
      'graded_by'             => new sfWidgetFormInputText(),
      'course_id'             => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Course'), 'add_empty' => false)),
      'created_at'            => new sfWidgetFormDateTime(),
      'updated_at'            => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                    => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'title'                 => new sfValidatorString(array('max_length' => 255)),
      'assignment_group_id'   => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('AssignmentGroup'))),
      'description'           => new sfValidatorString(),
      'submission'            => new sfValidatorInteger(),
      'due_date'              => new sfValidatorDateTime(array('required' => false)),
      'points'                => new sfValidatorInteger(),
      'weight'                => new sfValidatorNumber(array('required' => false)),
      'lock_until'            => new sfValidatorDateTime(array('required' => false)),
      'lock_after'            => new sfValidatorDateTime(array('required' => false)),
      'notify_users'          => new sfValidatorBoolean(array('required' => false)),
      'is_graded'             => new sfValidatorBoolean(array('required' => false)),
      'allow_late_submission' => new sfValidatorBoolean(array('required' => false)),
      'graded_by'             => new sfValidatorInteger(),
      'course_id'             => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Course'))),
      'created_at'            => new sfValidatorDateTime(),
      'updated_at'            => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('assignment[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Assignment';
  }

}
